﻿

namespace Mulala.Cavan.Domain.MainBoundedContext.MulalaModule
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Mulala.Cavan.Core.Persistent;
    using Mulala.Cavan.Domain.MainBoundedContext.NannyModule;
    using Mulala.Cavan.Domain.MainBoundedContext.SearchModule;
    using Mulala.Cavan.Core.MyLinq;

    public class NannyDiarySpecification : ISpecification<NannyDiary, NannyDiarySearch>
    {
        #region ISpecification<NannyDiary,NannyDiarySearch> Members

        public NannyDiarySearch SearchParams
        {
            get;
            set;
        }

        #endregion

        #region ISpecification<NannyDiary> Members

        public System.Linq.Expressions.Expression<Func<NannyDiary, bool>> Expression
        {
            get 
            {
                IQueryBuilder<NannyDiary> queryBuilder = QueryBuilder.Create<NannyDiary>();

                if (null != SearchParams)
                {
                    if (SearchParams.NannyID > 0)
                    {
                        queryBuilder = queryBuilder.Equals(nd => nd.Nanny.ID, SearchParams.NannyID);
                    }
                }

                return queryBuilder.Expression.Expand();
            }
        }

        #endregion
    }
}
